<!--批发销货单主表-->
<script setup lang="ts">
    import {AxiosPromise} from "axios";
    import lodash from 'lodash-es'

    defineOptions({
        name: "OdsErpRetailWholesaleOrderMain",
        inheritAttrs: false,
    });

    import {ElLoading, UploadFile} from "element-plus";
    import {
        getOdsErpRetailWholesaleOrderMainPage,
        getOdsErpRetailWholesaleOrderMainForm,
        saveOdsErpRetailWholesaleOrderMain,
        deleteOdsErpRetailWholesaleOrderMain,
        importOdsErpRetailWholesaleOrderMain,
        exportOdsErpRetailWholesaleOrderMain
    } from "@/api/odsErpRetailWholesaleOrderMain";

    const queryFormRef = ref(ElForm);
    const dataFormRef = ref(ElForm);

    const loading = ref(false);
    const ids = ref<number[]>([]);
    const total = ref(0);

    const queryParams = reactive<any>({
        pageNum: 1,
        pageSize: 20,
    });

    const odsErpRetailWholesaleOrderMainList = ref<[]>();

    const dialog = reactive<DialogOption>({
        visible: false,
    });
    const importDialog = reactive<DialogOption>({
        title: "批发销货单主表数据导入",
        visible: false,
    });

    const excelFile = ref<File>();
    const excelFilelist = ref<File[]>([]);
    const formData = reactive<any>({});

    const rules = reactive({
        djbh: [{ required: true, message: "请输入单据编号", trigger: "blur" }],
        rq: [{ required: true, message: "请输入日期", trigger: "blur" }],
        ydjh: [{ required: true, message: "请输入原单号", trigger: "blur" }],
        djxz: [{ required: true, message: "请输入作单标志", trigger: "blur" }],
        fplx: [{ required: true, message: "请输入换货设定", trigger: "blur" }],
        lxdj: [{ required: true, message: "请输入订单号", trigger: "blur" }],
        days: [{ required: true, message: "请输入换货周期", trigger: "blur" }],
        dm1: [{ required: true, message: "请输入客户", trigger: "blur" }],
        dm11: [{ required: true, message: "请输入", trigger: "blur" }],
        dm2: [{ required: true, message: "请输入仓库", trigger: "blur" }],
        dm21: [{ required: true, message: "请输入库位", trigger: "blur" }],
        dm3: [{ required: true, message: "请输入关联仓库", trigger: "blur" }],
        dm31: [{ required: true, message: "请输入关联库位", trigger: "blur" }],
        dm4: [{ required: true, message: "请输入发货类型", trigger: "blur" }],
        dm41: [{ required: true, message: "请输入折扣类型", trigger: "blur" }],
        qddm: [{ required: true, message: "请输入渠道", trigger: "blur" }],
        qydm: [{ required: true, message: "请输入", trigger: "blur" }],
        ygdm: [{ required: true, message: "请输入业务员", trigger: "blur" }],
        sl: [{ required: true, message: "请输入数量", trigger: "blur" }],
        sl1: [{ required: true, message: "请输入", trigger: "blur" }],
        sl2: [{ required: true, message: "请输入", trigger: "blur" }],
        sl3: [{ required: true, message: "请输入", trigger: "blur" }],
        bzsl: [{ required: true, message: "请输入", trigger: "blur" }],
        je: [{ required: true, message: "请输入金额", trigger: "blur" }],
        je1: [{ required: true, message: "请输入", trigger: "blur" }],
        je2: [{ required: true, message: "请输入", trigger: "blur" }],
        je3: [{ required: true, message: "请输入定金金额", trigger: "blur" }],
        bzje: [{ required: true, message: "请输入标准金额", trigger: "blur" }],
        cj: [{ required: true, message: "请输入换货率", trigger: "blur" }],
        tj: [{ required: true, message: "请输入提交", trigger: "blur" }],
        tjrq: [{ required: true, message: "请输入", trigger: "blur" }],
        xc: [{ required: true, message: "请输入下传", trigger: "blur" }],
        xcrq: [{ required: true, message: "请输入", trigger: "blur" }],
        ys: [{ required: true, message: "请输入发出", trigger: "blur" }],
        ysrq: [{ required: true, message: "请输入发出日期", trigger: "blur" }],
        jz: [{ required: true, message: "请输入记帐", trigger: "blur" }],
        jzrq: [{ required: true, message: "请输入记帐日期", trigger: "blur" }],
        js: [{ required: true, message: "请输入执行", trigger: "blur" }],
        jsrq: [{ required: true, message: "请输入", trigger: "blur" }],
        sh: [{ required: true, message: "请输入验收", trigger: "blur" }],
        shrq: [{ required: true, message: "请输入验收日期", trigger: "blur" }],
        sp: [{ required: true, message: "请输入", trigger: "blur" }],
        sprq: [{ required: true, message: "请输入", trigger: "blur" }],
        ll: [{ required: true, message: "请输入允许结算", trigger: "blur" }],
        llrq: [{ required: true, message: "请输入", trigger: "blur" }],
        zdr: [{ required: true, message: "请输入制单人", trigger: "blur" }],
        ysr: [{ required: true, message: "请输入发出人", trigger: "blur" }],
        jzr: [{ required: true, message: "请输入记帐人", trigger: "blur" }],
        jsr: [{ required: true, message: "请输入", trigger: "blur" }],
        shr: [{ required: true, message: "请输入验收人", trigger: "blur" }],
        spr: [{ required: true, message: "请输入", trigger: "blur" }],
        llr: [{ required: true, message: "请输入打印", trigger: "blur" }],
        yxrq: [{ required: true, message: "请输入预发货日", trigger: "blur" }],
        rq1: [{ required: true, message: "请输入锁定日期", trigger: "blur" }],
        rq2: [{ required: true, message: "请输入解锁日期", trigger: "blur" }],
        rq3: [{ required: true, message: "请输入", trigger: "blur" }],
        rq4: [{ required: true, message: "请输入制单日", trigger: "blur" }],
        bz: [{ required: true, message: "请输入备注", trigger: "blur" }],
        byzd1: [{ required: true, message: "请输入价格选定", trigger: "blur" }],
        byzd2: [{ required: true, message: "请输入锁定", trigger: "blur" }],
        byzd3: [{ required: true, message: "请输入通知号", trigger: "blur" }],
        byzd4: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd5: [{ required: true, message: "请输入上次修改", trigger: "blur" }],
        byzd6: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd7: [{ required: true, message: "请输入订货会", trigger: "blur" }],
        byzd8: [{ required: true, message: "请输入配码件数", trigger: "blur" }],
        byzd9: [{ required: true, message: "请输入打印次数", trigger: "blur" }],
        byzd10: [{ required: true, message: "请输入锁定次数", trigger: "blur" }],
        byzd11: [{ required: true, message: "请输入配套数量", trigger: "blur" }],
        byzd12: [{ required: true, message: "请输入折扣", trigger: "blur" }],
        byzd13: [{ required: true, message: "请输入可发货额", trigger: "blur" }],
        byzd14: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd15: [{ required: true, message: "请输入", trigger: "blur" }],
        zs: [{ required: true, message: "请输入终审", trigger: "blur" }],
        zsr: [{ required: true, message: "请输入终审人", trigger: "blur" }],
        zsrq: [{ required: true, message: "请输入终审日期", trigger: "blur" }],
        dm5: [{ required: true, message: "请输入品牌", trigger: "blur" }],
        dm51: [{ required: true, message: "请输入", trigger: "blur" }],
        dm6: [{ required: true, message: "请输入", trigger: "blur" }],
        dm61: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd16: [{ required: true, message: "请输入锁定用户", trigger: "blur" }],
        byzd17: [{ required: true, message: "请输入解锁用户", trigger: "blur" }],
        byzd18: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd19: [{ required: true, message: "请输入", trigger: "blur" }],
        byzd20: [{ required: true, message: "请输入", trigger: "blur" }],
        hh: [{ required: true, message: "请输入换货计算", trigger: "blur" }],
        zdhhzq: [{ required: true, message: "请输入最大换货周期", trigger: "blur" }],
        whhk: [{ required: true, message: "请输入期外换货率", trigger: "blur" }],
        zdhhk: [{ required: true, message: "请输入追单后前单", trigger: "blur" }],
        jshb: [{ required: true, message: "请输入结算货币", trigger: "blur" }],
        hbhl: [{ required: true, message: "请输入汇率", trigger: "blur" }],
        fzxx: [{ required: true, message: "请输入分账信息", trigger: "blur" }],
        fp: [{ required: true, message: "请输入发票", trigger: "blur" }],
        xsfy: [{ required: true, message: "请输入记账生成销售费用单", trigger: "blur" }],
        zrje: [{ required: true, message: "请输入整单折让", trigger: "blur" }],
        zrhje: [{ required: true, message: "请输入折后金额", trigger: "blur" }],
        cx: [{ required: true, message: "请输入促销", trigger: "blur" }],
        isFocus: [{ required: true, message: "请输入关注", trigger: "blur" }],
        isMove: [{ required: true, message: "请输入", trigger: "blur" }],
        moveRq: [{ required: true, message: "请输入", trigger: "blur" }],
        lastChanged: [{ required: true, message: "请输入", trigger: "blur" }],
        isChanjet: [{ required: true, message: "请输入", trigger: "blur" }],
        flowStatus: [{ required: true, message: "请输入", trigger: "blur" }],
        dcf: [{ required: true, message: "请输入调出方", trigger: "blur" }],
        drf: [{ required: true, message: "请输入", trigger: "blur" }],
        tax: [{ required: true, message: "请输入税额", trigger: "blur" }],
        taxDc: [{ required: true, message: "请输入税额本位币", trigger: "blur" }],
        jeWithoutTax: [{ required: true, message: "请输入不含税金额", trigger: "blur" }],
        jeWithoutTaxDc: [{ required: true, message: "请输入不含税金额本位币", trigger: "blur" }],
        jeDc: [{ required: true, message: "请输入金额本位币", trigger: "blur" }],
        hc: [{ required: true, message: "请输入红冲", trigger: "blur" }],
        hcr: [{ required: true, message: "请输入红冲人", trigger: "blur" }],
        hcrq: [{ required: true, message: "请输入红冲日期", trigger: "blur" }],
        syflje: [{ required: true, message: "请输入返利金额", trigger: "blur" }],
        relatingOrderSn: [{ required: true, message: "请输入", trigger: "blur" }],
    });




    /**
     * 查询
     */
    function handleQuery() {
        loading.value = true;
        getOdsErpRetailWholesaleOrderMainPage(queryParams)
            .then(({ data }) => {
                odsErpRetailWholesaleOrderMainList.value = data.list;
                total.value = data.total;
            })
            .finally(() => {
                loading.value = false;
            });
    }

    /**
     * 重置查询
     */
    function resetQuery() {
        queryFormRef.value.resetFields();
        queryParams.pageNum = 1;
        handleQuery();
    }

    /**
     * 行checkbox change事件
     */
    function handleSelectionChange(selection: any) {
        ids.value = selection.map((item: any) => item.id);
    }

    /**
     * 打开字典类型表单弹窗
     *
     * @param dicTypeId 字典类型ID
     */
    function openDialog(id?: number) {
        dialog.visible = true;
        if (id) {
            dialog.title = "修改批发销货单主表";
            getOdsErpRetailWholesaleOrderMainForm(id).then(({ data }) => {
                Object.assign(formData, data);
            });
        } else {
            dialog.title = "新增批发销货单主表";
        }
    }

    /**
     * 字典类型表单提交
     */
    function handleSubmit() {
        dataFormRef.value.validate((isValid: boolean) => {
            if (isValid) {
                loading.value = false;
                saveOdsErpRetailWholesaleOrderMain(formData)
                    .then(() => {
                        ElMessage.success("保存成功");
                        closeDialog();
                        handleQuery();
                    })
                    .finally(() => (loading.value = false));
            }
        });
    }

    /**
     * 关闭弹窗
     */
    function closeDialog() {
        dialog.visible = false;
        resetForm();
    }

    /**
     * 重置表单
     */
    function resetForm() {
        dataFormRef.value.resetFields();
        dataFormRef.value.clearValidate();

        formData.id = undefined;
    }

    /**
     * 删除批发销货单主表
     */
    function handleDelete(id?: number) {
        const dictTypeIds = [id || ids.value].join(",");
        if (!dictTypeIds) {
            ElMessage.warning("请勾选删除项");
            return;
        }

        ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
        }).then(() => {
            deleteOdsErpRetailWholesaleOrderMain(dictTypeIds).then(() => {
                ElMessage.success("删除成功");
                resetQuery();
            });
        });
    }

    /** 打开导入弹窗 */
    async function openImportDialog() {
        importDialog.visible = true;
    }

    /**
     * Excel文件change事件
     *
     * @param file
     */
    function handleExcelChange(file: UploadFile) {
        if (file.size !== undefined) {
            if (file.size > 20*1024*1024) {
                ElMessage.warning("上传文件大小不能超过20M");
                return false
            }
        }
        if (!/\.(xlsx|xls|XLSX|XLS)$/.test(file.name)) {
            ElMessage.warning("上传Excel只能为xlsx、xls格式");
            excelFile.value = undefined;
            excelFilelist.value = [];
            return false;
        }
        excelFile.value = file.raw;
    }

    /** 导入提交 */
    function handleImport() {
        if (!excelFile.value) {
            ElMessage.warning("上传Excel文件不能为空");
            return false;
        }
        const importLoading = ElLoading.service({
            lock: true,
            text: '导入中...',
            background: 'rgba(0, 0, 0, 0.7)',
        })
        importOdsErpRetailWholesaleOrderMain(excelFile.value).then((response) => {

            closeImportDialog();
            ElMessage.success('导入成功');
            resetQuery();
        }).finally(() => importLoading.close());
    }

    /**  关闭导入弹窗 */
    function closeImportDialog() {
        importDialog.visible = false;
        excelFile.value = undefined;
        excelFilelist.value = [];
    }

    /** 导出批发销货单主表 */
    function handleExport() {
        const strIds = [ids.value].join(",");
        exportOdsErpRetailWholesaleOrderMain(strIds).then((response: any) => {
            const blob = new Blob([response.data], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
            });
            const a = document.createElement("a");
            const href = window.URL.createObjectURL(blob); // 下载的链接
            a.href = href;
            a.download = decodeURI(
                response.headers["content-disposition"].split(";")[1].split("=")[1]
            ); // 获取后台设置的文件名称
            document.body.appendChild(a);
            a.click(); // 点击导出
            document.body.removeChild(a); // 下载完成移除元素
            window.URL.revokeObjectURL(href); // 释放掉blob对象
        });
    }

    onMounted(() => {
        handleQuery();
    });
</script>

<template>
    <div class="app-container">
        <div class="search-container">
            <el-form ref="queryFormRef" :model="queryParams" :inline="true">
                <el-form-item label="关键词" prop="keywords">
                    <el-input
                            v-model="queryParams.keywords"
                            placeholder="关键词"
                            clearable
                            @keyup.enter="handleQuery"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleQuery()"
                    ><i-ep-search />搜索</el-button
                    >
                    <el-button @click="resetQuery()"><i-ep-refresh />重置</el-button>
                </el-form-item>
            </el-form>
        </div>

        <el-card shadow="never">
            <template #header>
                <div class="flex justify-between">
                    <div>
                        <el-button
                                v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:save']"
                                type="success"
                                @click="openDialog()"
                        ><i-ep-plus />新增</el-button
                        >
                        <el-button
                                type="danger"
                                :disabled="ids.length === 0"
                                @click="handleDelete()"
                                v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:delete']"
                        ><i-ep-delete />删除</el-button
                        >
                    </div>
                    <div>
                        <el-button class="ml-3" @click="openImportDialog" v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:import']"
                        ><template #icon><i-ep-top /></template>导入</el-button
                        >
                        <el-button class="ml-3" @click="handleExport" v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:export']"
                        ><template #icon><i-ep-download /></template>导出</el-button
                        >
                    </div>
                </div>
            </template>
            <el-table
                    size="small"
                    :header-row-style="{color: 'dimgray'}"
                    v-loading="loading"
                    highlight-current-row
                    :data="odsErpRetailWholesaleOrderMainList"
                    border
                    @selection-change="handleSelectionChange"
                    :height="odsErpRetailWholesaleOrderMainList && odsErpRetailWholesaleOrderMainList.length > 0 ? 580 : 130"
            >
                <el-table-column type="selection" width="40" align="center" show-overflow-tooltip />
                <el-table-column label="单据编号" prop="djbh" width="100" show-overflow-tooltip/>
                <el-table-column label="日期" prop="rq" width="100" show-overflow-tooltip/>
                <el-table-column label="原单号" prop="ydjh" width="100" show-overflow-tooltip/>
                <el-table-column label="作单标志" prop="djxz" width="100" show-overflow-tooltip/>
                <el-table-column label="换货设定" prop="fplx" width="100" show-overflow-tooltip/>
                <el-table-column label="订单号" prop="lxdj" width="100" show-overflow-tooltip/>
                <el-table-column label="换货周期" prop="days" width="100" show-overflow-tooltip/>
                <el-table-column label="客户" prop="dm1" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="dm11" width="100" show-overflow-tooltip/>
                <el-table-column label="仓库" prop="dm2" width="100" show-overflow-tooltip/>
                <el-table-column label="库位" prop="dm21" width="100" show-overflow-tooltip/>
                <el-table-column label="关联仓库" prop="dm3" width="100" show-overflow-tooltip/>
                <el-table-column label="关联库位" prop="dm31" width="100" show-overflow-tooltip/>
                <el-table-column label="发货类型" prop="dm4" width="100" show-overflow-tooltip/>
                <el-table-column label="折扣类型" prop="dm41" width="100" show-overflow-tooltip/>
                <el-table-column label="渠道" prop="qddm" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="qydm" width="100" show-overflow-tooltip/>
                <el-table-column label="业务员" prop="ygdm" width="100" show-overflow-tooltip/>
                <el-table-column label="数量" prop="sl" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="sl1" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="sl2" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="sl3" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="bzsl" width="100" show-overflow-tooltip/>
                <el-table-column label="金额" prop="je" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="je1" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="je2" width="100" show-overflow-tooltip/>
                <el-table-column label="定金金额" prop="je3" width="100" show-overflow-tooltip/>
                <el-table-column label="标准金额" prop="bzje" width="100" show-overflow-tooltip/>
                <el-table-column label="换货率" prop="cj" width="100" show-overflow-tooltip/>
                <el-table-column label="提交" prop="tj" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="tjrq" width="100" show-overflow-tooltip/>
                <el-table-column label="下传" prop="xc" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="xcrq" width="100" show-overflow-tooltip/>
                <el-table-column label="发出" prop="ys" width="100" show-overflow-tooltip/>
                <el-table-column label="发出日期" prop="ysrq" width="100" show-overflow-tooltip/>
                <el-table-column label="记帐" prop="jz" width="100" show-overflow-tooltip/>
                <el-table-column label="记帐日期" prop="jzrq" width="100" show-overflow-tooltip/>
                <el-table-column label="执行" prop="js" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="jsrq" width="100" show-overflow-tooltip/>
                <el-table-column label="验收" prop="sh" width="100" show-overflow-tooltip/>
                <el-table-column label="验收日期" prop="shrq" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="sp" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="sprq" width="100" show-overflow-tooltip/>
                <el-table-column label="允许结算" prop="ll" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="llrq" width="100" show-overflow-tooltip/>
                <el-table-column label="制单人" prop="zdr" width="100" show-overflow-tooltip/>
                <el-table-column label="发出人" prop="ysr" width="100" show-overflow-tooltip/>
                <el-table-column label="记帐人" prop="jzr" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="jsr" width="100" show-overflow-tooltip/>
                <el-table-column label="验收人" prop="shr" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="spr" width="100" show-overflow-tooltip/>
                <el-table-column label="打印" prop="llr" width="100" show-overflow-tooltip/>
                <el-table-column label="预发货日" prop="yxrq" width="100" show-overflow-tooltip/>
                <el-table-column label="锁定日期" prop="rq1" width="100" show-overflow-tooltip/>
                <el-table-column label="解锁日期" prop="rq2" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="rq3" width="100" show-overflow-tooltip/>
                <el-table-column label="制单日" prop="rq4" width="100" show-overflow-tooltip/>
                <el-table-column label="备注" prop="bz" width="100" show-overflow-tooltip/>
                <el-table-column label="价格选定" prop="byzd1" width="100" show-overflow-tooltip/>
                <el-table-column label="锁定" prop="byzd2" width="100" show-overflow-tooltip/>
                <el-table-column label="通知号" prop="byzd3" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd4" width="100" show-overflow-tooltip/>
                <el-table-column label="上次修改" prop="byzd5" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd6" width="100" show-overflow-tooltip/>
                <el-table-column label="订货会" prop="byzd7" width="100" show-overflow-tooltip/>
                <el-table-column label="配码件数" prop="byzd8" width="100" show-overflow-tooltip/>
                <el-table-column label="打印次数" prop="byzd9" width="100" show-overflow-tooltip/>
                <el-table-column label="锁定次数" prop="byzd10" width="100" show-overflow-tooltip/>
                <el-table-column label="配套数量" prop="byzd11" width="100" show-overflow-tooltip/>
                <el-table-column label="折扣" prop="byzd12" width="100" show-overflow-tooltip/>
                <el-table-column label="可发货额" prop="byzd13" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd14" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd15" width="100" show-overflow-tooltip/>
                <el-table-column label="终审" prop="zs" width="100" show-overflow-tooltip/>
                <el-table-column label="终审人" prop="zsr" width="100" show-overflow-tooltip/>
                <el-table-column label="终审日期" prop="zsrq" width="100" show-overflow-tooltip/>
                <el-table-column label="品牌" prop="dm5" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="dm51" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="dm6" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="dm61" width="100" show-overflow-tooltip/>
                <el-table-column label="锁定用户" prop="byzd16" width="100" show-overflow-tooltip/>
                <el-table-column label="解锁用户" prop="byzd17" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd18" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd19" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="byzd20" width="100" show-overflow-tooltip/>
                <el-table-column label="换货计算" prop="hh" width="100" show-overflow-tooltip/>
                <el-table-column label="最大换货周期" prop="zdhhzq" width="100" show-overflow-tooltip/>
                <el-table-column label="期外换货率" prop="whhk" width="100" show-overflow-tooltip/>
                <el-table-column label="追单后前单" prop="zdhhk" width="100" show-overflow-tooltip/>
                <el-table-column label="结算货币" prop="jshb" width="100" show-overflow-tooltip/>
                <el-table-column label="汇率" prop="hbhl" width="100" show-overflow-tooltip/>
                <el-table-column label="分账信息" prop="fzxx" width="100" show-overflow-tooltip/>
                <el-table-column label="发票" prop="fp" width="100" show-overflow-tooltip/>
                <el-table-column label="记账生成销售费用单" prop="xsfy" width="100" show-overflow-tooltip/>
                <el-table-column label="整单折让" prop="zrje" width="100" show-overflow-tooltip/>
                <el-table-column label="折后金额" prop="zrhje" width="100" show-overflow-tooltip/>
                <el-table-column label="促销" prop="cx" width="100" show-overflow-tooltip/>
                <el-table-column label="关注" prop="isFocus" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="isMove" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="moveRq" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="lastChanged" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="isChanjet" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="flowStatus" width="100" show-overflow-tooltip/>
                <el-table-column label="调出方" prop="dcf" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="drf" width="100" show-overflow-tooltip/>
                <el-table-column label="税额" prop="tax" width="100" show-overflow-tooltip/>
                <el-table-column label="税额本位币" prop="taxDc" width="100" show-overflow-tooltip/>
                <el-table-column label="不含税金额" prop="jeWithoutTax" width="100" show-overflow-tooltip/>
                <el-table-column label="不含税金额本位币" prop="jeWithoutTaxDc" width="100" show-overflow-tooltip/>
                <el-table-column label="金额本位币" prop="jeDc" width="100" show-overflow-tooltip/>
                <el-table-column label="红冲" prop="hc" width="100" show-overflow-tooltip/>
                <el-table-column label="红冲人" prop="hcr" width="100" show-overflow-tooltip/>
                <el-table-column label="红冲日期" prop="hcrq" width="100" show-overflow-tooltip/>
                <el-table-column label="返利金额" prop="syflje" width="100" show-overflow-tooltip/>
                <el-table-column label="" prop="relatingOrderSn" width="100" show-overflow-tooltip/>
                <el-table-column label="" show-overflow-tooltip/>
                <el-table-column fixed="right" label="操作" align="center" width="120">
                    <template #default="scope">
                        <el-button
                                v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:save']"
                                type="primary"
                                link
                                size="small"
                                @click.stop="openDialog(scope.row.id)"
                        ><i-ep-edit />编辑</el-button
                        >
                        <el-button
                                v-hasPerm="['sys:odsErpRetailWholesaleOrderMain:delete']"
                                type="primary"
                                link
                                size="small"
                                @click.stop="handleDelete(scope.row.id)"
                        ><i-ep-delete />删除</el-button
                        >
                    </template>
                </el-table-column>
            </el-table>

            <pagination
                    v-if="total > 0"
                    v-model:total="total"
                    v-model:page="queryParams.pageNum"
                    v-model:limit="queryParams.pageSize"
                    @pagination="handleQuery"
            />
        </el-card>

        <el-dialog
                v-model="dialog.visible"
                :title="dialog.title"
                width="500px"
                :close-on-click-modal="false"
                @close="closeDialog"
        >
            <el-form
                    ref="dataFormRef"
                    :model="formData"
                    :rules="rules"
                    label-width="150px"
            >
                    <el-form-item label="单据编号" prop="djbh">
                        <el-input v-model="formData.djbh" placeholder="请输入单据编号" clearable/>
                    </el-form-item>
                    <el-form-item label="日期" prop="rq">
                        <el-input v-model="formData.rq" placeholder="请输入日期" clearable/>
                    </el-form-item>
                    <el-form-item label="原单号" prop="ydjh">
                        <el-input v-model="formData.ydjh" placeholder="请输入原单号" clearable/>
                    </el-form-item>
                    <el-form-item label="作单标志" prop="djxz">
                        <el-input v-model="formData.djxz" placeholder="请输入作单标志" clearable/>
                    </el-form-item>
                    <el-form-item label="换货设定" prop="fplx">
                        <el-input v-model="formData.fplx" placeholder="请输入换货设定" clearable/>
                    </el-form-item>
                    <el-form-item label="订单号" prop="lxdj">
                        <el-input v-model="formData.lxdj" placeholder="请输入订单号" clearable/>
                    </el-form-item>
                    <el-form-item label="换货周期" prop="days">
                        <el-input v-model="formData.days" placeholder="请输入换货周期" clearable/>
                    </el-form-item>
                    <el-form-item label="客户" prop="dm1">
                        <el-input v-model="formData.dm1" placeholder="请输入客户" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="dm11">
                        <el-input v-model="formData.dm11" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="仓库" prop="dm2">
                        <el-input v-model="formData.dm2" placeholder="请输入仓库" clearable/>
                    </el-form-item>
                    <el-form-item label="库位" prop="dm21">
                        <el-input v-model="formData.dm21" placeholder="请输入库位" clearable/>
                    </el-form-item>
                    <el-form-item label="关联仓库" prop="dm3">
                        <el-input v-model="formData.dm3" placeholder="请输入关联仓库" clearable/>
                    </el-form-item>
                    <el-form-item label="关联库位" prop="dm31">
                        <el-input v-model="formData.dm31" placeholder="请输入关联库位" clearable/>
                    </el-form-item>
                    <el-form-item label="发货类型" prop="dm4">
                        <el-input v-model="formData.dm4" placeholder="请输入发货类型" clearable/>
                    </el-form-item>
                    <el-form-item label="折扣类型" prop="dm41">
                        <el-input v-model="formData.dm41" placeholder="请输入折扣类型" clearable/>
                    </el-form-item>
                    <el-form-item label="渠道" prop="qddm">
                        <el-input v-model="formData.qddm" placeholder="请输入渠道" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="qydm">
                        <el-input v-model="formData.qydm" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="业务员" prop="ygdm">
                        <el-input v-model="formData.ygdm" placeholder="请输入业务员" clearable/>
                    </el-form-item>
                    <el-form-item label="数量" prop="sl">
                        <el-input v-model="formData.sl" placeholder="请输入数量" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="sl1">
                        <el-input v-model="formData.sl1" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="sl2">
                        <el-input v-model="formData.sl2" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="sl3">
                        <el-input v-model="formData.sl3" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="bzsl">
                        <el-input v-model="formData.bzsl" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="金额" prop="je">
                        <el-input v-model="formData.je" placeholder="请输入金额" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="je1">
                        <el-input v-model="formData.je1" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="je2">
                        <el-input v-model="formData.je2" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="定金金额" prop="je3">
                        <el-input v-model="formData.je3" placeholder="请输入定金金额" clearable/>
                    </el-form-item>
                    <el-form-item label="标准金额" prop="bzje">
                        <el-input v-model="formData.bzje" placeholder="请输入标准金额" clearable/>
                    </el-form-item>
                    <el-form-item label="换货率" prop="cj">
                        <el-input v-model="formData.cj" placeholder="请输入换货率" clearable/>
                    </el-form-item>
                    <el-form-item label="提交" prop="tj">
                        <el-input v-model="formData.tj" placeholder="请输入提交" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="tjrq">
                        <el-input v-model="formData.tjrq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="下传" prop="xc">
                        <el-input v-model="formData.xc" placeholder="请输入下传" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="xcrq">
                        <el-input v-model="formData.xcrq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="发出" prop="ys">
                        <el-input v-model="formData.ys" placeholder="请输入发出" clearable/>
                    </el-form-item>
                    <el-form-item label="发出日期" prop="ysrq">
                        <el-input v-model="formData.ysrq" placeholder="请输入发出日期" clearable/>
                    </el-form-item>
                    <el-form-item label="记帐" prop="jz">
                        <el-input v-model="formData.jz" placeholder="请输入记帐" clearable/>
                    </el-form-item>
                    <el-form-item label="记帐日期" prop="jzrq">
                        <el-input v-model="formData.jzrq" placeholder="请输入记帐日期" clearable/>
                    </el-form-item>
                    <el-form-item label="执行" prop="js">
                        <el-input v-model="formData.js" placeholder="请输入执行" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="jsrq">
                        <el-input v-model="formData.jsrq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="验收" prop="sh">
                        <el-input v-model="formData.sh" placeholder="请输入验收" clearable/>
                    </el-form-item>
                    <el-form-item label="验收日期" prop="shrq">
                        <el-input v-model="formData.shrq" placeholder="请输入验收日期" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="sp">
                        <el-input v-model="formData.sp" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="sprq">
                        <el-input v-model="formData.sprq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="允许结算" prop="ll">
                        <el-input v-model="formData.ll" placeholder="请输入允许结算" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="llrq">
                        <el-input v-model="formData.llrq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="制单人" prop="zdr">
                        <el-input v-model="formData.zdr" placeholder="请输入制单人" clearable/>
                    </el-form-item>
                    <el-form-item label="发出人" prop="ysr">
                        <el-input v-model="formData.ysr" placeholder="请输入发出人" clearable/>
                    </el-form-item>
                    <el-form-item label="记帐人" prop="jzr">
                        <el-input v-model="formData.jzr" placeholder="请输入记帐人" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="jsr">
                        <el-input v-model="formData.jsr" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="验收人" prop="shr">
                        <el-input v-model="formData.shr" placeholder="请输入验收人" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="spr">
                        <el-input v-model="formData.spr" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="打印" prop="llr">
                        <el-input v-model="formData.llr" placeholder="请输入打印" clearable/>
                    </el-form-item>
                    <el-form-item label="预发货日" prop="yxrq">
                        <el-input v-model="formData.yxrq" placeholder="请输入预发货日" clearable/>
                    </el-form-item>
                    <el-form-item label="锁定日期" prop="rq1">
                        <el-input v-model="formData.rq1" placeholder="请输入锁定日期" clearable/>
                    </el-form-item>
                    <el-form-item label="解锁日期" prop="rq2">
                        <el-input v-model="formData.rq2" placeholder="请输入解锁日期" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="rq3">
                        <el-input v-model="formData.rq3" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="制单日" prop="rq4">
                        <el-input v-model="formData.rq4" placeholder="请输入制单日" clearable/>
                    </el-form-item>
                    <el-form-item label="备注" prop="bz">
                        <el-input v-model="formData.bz" placeholder="请输入备注" clearable/>
                    </el-form-item>
                    <el-form-item label="价格选定" prop="byzd1">
                        <el-input v-model="formData.byzd1" placeholder="请输入价格选定" clearable/>
                    </el-form-item>
                    <el-form-item label="锁定" prop="byzd2">
                        <el-input v-model="formData.byzd2" placeholder="请输入锁定" clearable/>
                    </el-form-item>
                    <el-form-item label="通知号" prop="byzd3">
                        <el-input v-model="formData.byzd3" placeholder="请输入通知号" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd4">
                        <el-input v-model="formData.byzd4" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="上次修改" prop="byzd5">
                        <el-input v-model="formData.byzd5" placeholder="请输入上次修改" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd6">
                        <el-input v-model="formData.byzd6" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="订货会" prop="byzd7">
                        <el-input v-model="formData.byzd7" placeholder="请输入订货会" clearable/>
                    </el-form-item>
                    <el-form-item label="配码件数" prop="byzd8">
                        <el-input v-model="formData.byzd8" placeholder="请输入配码件数" clearable/>
                    </el-form-item>
                    <el-form-item label="打印次数" prop="byzd9">
                        <el-input v-model="formData.byzd9" placeholder="请输入打印次数" clearable/>
                    </el-form-item>
                    <el-form-item label="锁定次数" prop="byzd10">
                        <el-input v-model="formData.byzd10" placeholder="请输入锁定次数" clearable/>
                    </el-form-item>
                    <el-form-item label="配套数量" prop="byzd11">
                        <el-input v-model="formData.byzd11" placeholder="请输入配套数量" clearable/>
                    </el-form-item>
                    <el-form-item label="折扣" prop="byzd12">
                        <el-input v-model="formData.byzd12" placeholder="请输入折扣" clearable/>
                    </el-form-item>
                    <el-form-item label="可发货额" prop="byzd13">
                        <el-input v-model="formData.byzd13" placeholder="请输入可发货额" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd14">
                        <el-input v-model="formData.byzd14" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd15">
                        <el-input v-model="formData.byzd15" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="终审" prop="zs">
                        <el-input v-model="formData.zs" placeholder="请输入终审" clearable/>
                    </el-form-item>
                    <el-form-item label="终审人" prop="zsr">
                        <el-input v-model="formData.zsr" placeholder="请输入终审人" clearable/>
                    </el-form-item>
                    <el-form-item label="终审日期" prop="zsrq">
                        <el-input v-model="formData.zsrq" placeholder="请输入终审日期" clearable/>
                    </el-form-item>
                    <el-form-item label="品牌" prop="dm5">
                        <el-input v-model="formData.dm5" placeholder="请输入品牌" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="dm51">
                        <el-input v-model="formData.dm51" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="dm6">
                        <el-input v-model="formData.dm6" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="dm61">
                        <el-input v-model="formData.dm61" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="锁定用户" prop="byzd16">
                        <el-input v-model="formData.byzd16" placeholder="请输入锁定用户" clearable/>
                    </el-form-item>
                    <el-form-item label="解锁用户" prop="byzd17">
                        <el-input v-model="formData.byzd17" placeholder="请输入解锁用户" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd18">
                        <el-input v-model="formData.byzd18" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd19">
                        <el-input v-model="formData.byzd19" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="byzd20">
                        <el-input v-model="formData.byzd20" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="换货计算" prop="hh">
                        <el-input v-model="formData.hh" placeholder="请输入换货计算" clearable/>
                    </el-form-item>
                    <el-form-item label="最大换货周期" prop="zdhhzq">
                        <el-input v-model="formData.zdhhzq" placeholder="请输入最大换货周期" clearable/>
                    </el-form-item>
                    <el-form-item label="期外换货率" prop="whhk">
                        <el-input v-model="formData.whhk" placeholder="请输入期外换货率" clearable/>
                    </el-form-item>
                    <el-form-item label="追单后前单" prop="zdhhk">
                        <el-input v-model="formData.zdhhk" placeholder="请输入追单后前单" clearable/>
                    </el-form-item>
                    <el-form-item label="结算货币" prop="jshb">
                        <el-input v-model="formData.jshb" placeholder="请输入结算货币" clearable/>
                    </el-form-item>
                    <el-form-item label="汇率" prop="hbhl">
                        <el-input v-model="formData.hbhl" placeholder="请输入汇率" clearable/>
                    </el-form-item>
                    <el-form-item label="分账信息" prop="fzxx">
                        <el-input v-model="formData.fzxx" placeholder="请输入分账信息" clearable/>
                    </el-form-item>
                    <el-form-item label="发票" prop="fp">
                        <el-input v-model="formData.fp" placeholder="请输入发票" clearable/>
                    </el-form-item>
                    <el-form-item label="记账生成销售费用单" prop="xsfy">
                        <el-input v-model="formData.xsfy" placeholder="请输入记账生成销售费用单" clearable/>
                    </el-form-item>
                    <el-form-item label="整单折让" prop="zrje">
                        <el-input v-model="formData.zrje" placeholder="请输入整单折让" clearable/>
                    </el-form-item>
                    <el-form-item label="折后金额" prop="zrhje">
                        <el-input v-model="formData.zrhje" placeholder="请输入折后金额" clearable/>
                    </el-form-item>
                    <el-form-item label="促销" prop="cx">
                        <el-input v-model="formData.cx" placeholder="请输入促销" clearable/>
                    </el-form-item>
                    <el-form-item label="关注" prop="isFocus">
                        <el-input v-model="formData.isFocus" placeholder="请输入关注" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="isMove">
                        <el-input v-model="formData.isMove" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="moveRq">
                        <el-input v-model="formData.moveRq" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="lastChanged">
                        <el-input v-model="formData.lastChanged" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="isChanjet">
                        <el-input v-model="formData.isChanjet" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="flowStatus">
                        <el-input v-model="formData.flowStatus" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="调出方" prop="dcf">
                        <el-input v-model="formData.dcf" placeholder="请输入调出方" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="drf">
                        <el-input v-model="formData.drf" placeholder="请输入" clearable/>
                    </el-form-item>
                    <el-form-item label="税额" prop="tax">
                        <el-input v-model="formData.tax" placeholder="请输入税额" clearable/>
                    </el-form-item>
                    <el-form-item label="税额本位币" prop="taxDc">
                        <el-input v-model="formData.taxDc" placeholder="请输入税额本位币" clearable/>
                    </el-form-item>
                    <el-form-item label="不含税金额" prop="jeWithoutTax">
                        <el-input v-model="formData.jeWithoutTax" placeholder="请输入不含税金额" clearable/>
                    </el-form-item>
                    <el-form-item label="不含税金额本位币" prop="jeWithoutTaxDc">
                        <el-input v-model="formData.jeWithoutTaxDc" placeholder="请输入不含税金额本位币" clearable/>
                    </el-form-item>
                    <el-form-item label="金额本位币" prop="jeDc">
                        <el-input v-model="formData.jeDc" placeholder="请输入金额本位币" clearable/>
                    </el-form-item>
                    <el-form-item label="红冲" prop="hc">
                        <el-input v-model="formData.hc" placeholder="请输入红冲" clearable/>
                    </el-form-item>
                    <el-form-item label="红冲人" prop="hcr">
                        <el-input v-model="formData.hcr" placeholder="请输入红冲人" clearable/>
                    </el-form-item>
                    <el-form-item label="红冲日期" prop="hcrq">
                        <el-input v-model="formData.hcrq" placeholder="请输入红冲日期" clearable/>
                    </el-form-item>
                    <el-form-item label="返利金额" prop="syflje">
                        <el-input v-model="formData.syflje" placeholder="请输入返利金额" clearable/>
                    </el-form-item>
                    <el-form-item label="" prop="relatingOrderSn">
                        <el-input v-model="formData.relatingOrderSn" placeholder="请输入" clearable/>
                    </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="handleSubmit">确 定</el-button>
                    <el-button @click="closeDialog">取 消</el-button>
                </div>
            </template>
        </el-dialog>

        <!-- 导入弹窗 -->
        <el-dialog
                v-model="importDialog.visible"
                :title="importDialog.title"
                width="600px"
                append-to-body
                @close="closeImportDialog"
        >
            <el-form label-width="80px">
                <el-form-item label="Excel">
                    <el-upload
                            class="upload-demo"
                            action=""
                            drag
                            :auto-upload="false"
                            accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
                            :file-list="excelFilelist"
                            :on-change="handleExcelChange"
                            :limit="1"
                    >
                        <el-icon class="el-icon--upload">
                            <i-ep-upload-filled/>
                        </el-icon>
                        <div class="el-upload__text">
                            将文件拖到此处，或
                            <em>点击上传</em>
                        </div>
                        <template #tip>
                            <div class="el-upload__tip">xls/xlsx files</div>
                        </template>
                    </el-upload>
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="handleImport">确 定</el-button>
                    <el-button @click="closeImportDialog">取 消</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>
